#!/usr/bin/python
#coding=utf-8
import os
import urllib
import sys
import re


#oppo = 'http://bbs.coloros.com/forum.php?mod=phones&code=rom&pid=125'
def oppo_phone(url):

	page = urllib.urlopen(url)

	html = page.read()

	if html.find('此产品不存在') > 0:
		return
	
	#print url

	rom_pattern = re.compile('http://fs.*zip')

	rom_list = re.findall(rom_pattern, html)

	for r in rom_list:
		print r

	page.close()
def oppo_main(base):

	page = urllib.urlopen(base)	

	html = page.read()

	print html

	phone_pattern = re.compile(r'forum\.php\?mod=phones&code=rom&pid=[0-9]+&mobile=[0-9]+')

	phone_list = re.findall(phone_pattern, html)

	for p in phone_list:
		print p

	page.close()

for i in range(0, 138):
	u = 'http://bbs.coloros.com/forum.php?mod=phones&code=rom&pid=%d' % i
	oppo_phone(u)
